import java.util.Random;
import java.util.Scanner;
public class Test {
    public static void main(String[] args) {
       int[] lucknums=createlucknum();
       int []usernumbers=userinputnumbers();
       //判断中奖逻辑
        judge(lucknums,usernumbers);

    }
    public static void judge(int []lucknums,int []usernumbers) {
        //判断是否中奖
        //定义两个变量分别存储红球的命中个数和蓝球的命中个数
        int redgetnumbers = 0;
        int bluegetnumbers = 0;
        //嵌套循环
        for (int i = 0; i < usernumbers.length - 1; i++) {
            for (int j = 0; j < lucknums.length - 1; j++) {
                //每次找到相等的意味着当前的号码命中
                if (usernumbers[i] == lucknums[j]) {
                    redgetnumbers++;
                    break;
                }
            }
        }
        //判断蓝球号码是否命中,等于1命中，等于0没中

        bluegetnumbers = lucknums[6] == usernumbers[6] ? 1 : 0;
        System.out.println("中奖号码是");
        printarry(lucknums);
        System.out.println("您投注的号码是");
        printarry(usernumbers);
        System.out.println("您命中了红球"+redgetnumbers);
        System.out.println("您是命中蓝球："+(bluegetnumbers==1?"是":"否"));
        if(bluegetnumbers==1&&redgetnumbers<3){
            System.out.println("恭喜您中了5元");
        } else if (bluegetnumbers==1&&redgetnumbers==3||bluegetnumbers==0&&redgetnumbers==4) {
            System.out.println("恭喜您中了10元");
        }else if (bluegetnumbers==1&&redgetnumbers==4||bluegetnumbers==0&&redgetnumbers==5) {
            System.out.println("恭喜您中了200元");
    }else if (bluegetnumbers==1&&redgetnumbers==5) {
            System.out.println("恭喜您中了3000元");}
        else if (bluegetnumbers==0&&redgetnumbers==6) {
            System.out.println("恭喜您中了500万元");}
        else if (bluegetnumbers==1&&redgetnumbers==6) {
            System.out.println("恭喜您中了1000万元");}
        else{
            System.out.println("感谢你为彩票事业做出的共献");
        }

    }
    public static void printarry(int [] arr){
        for (int i = 0; i <arr.length; i++) {
            System.out.print(arr[i]+"\t");
        }
        System.out.println();
    }
public static int[]userinputnumbers(){
        //定义一个数组存储7个号码，动态初始化
    int []numbers=new int[7];
    //录入6个红球号码
    Scanner sc=new Scanner(System.in);
    for (int i = 0; i <numbers.length-1; i++) {
        System.out.println("请你输入第"+(i+1)+"个红球号码：");
        int data=sc.nextInt();
        //c.当前数据录入其中去
        numbers[i]=data;
    }
    //单独录入一个号码
    System.out.println("请您输入蓝球号码（1-16）");
    numbers[6]=sc.nextInt();
    return numbers;//返回的是地址
}
    public static int[] createlucknum() {
        //定义动态数组存储7个数据
        int[] numbers = new int[7];
        //遍历数组，为每个位置生成号码，注意前6个位置，生成不重复的号码
        for (int i = 0; i < numbers.length - 1; i++) {
            Random r = new Random();
            for (int i1 = 0; i1 < numbers.length; i1++) {
                //为当前位置找出一个不重复的1~33之间的数字
                while (true) {
                    int data = r.nextInt(33) + 1;//1~33（0~32）+1
                    //必须当前随机号码是否出现过，直到不重复为止存进去
                    //定义一个标记为：默认data是没有重复的
                    boolean flag = true;
                    for (int j = 0; j < i; j++) {
                        if (numbers[j] == data) {
                            //data数据之前出现过不能用
                            flag = false;
                            break;
                        }
                    }
                    if (flag == true) {
                        //data数据之前没有出现过
                        numbers[i] = data;
                        break;
                    }

                }
            }

            numbers[numbers.length - 1] = r.nextInt(16) - 1;}
        return numbers;

    }
}


